import Vue from 'vue'
import Vuex from 'vuex';
//npm install --save vuex-persistedstate 用这个来让vuex数据保存在本地
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

export default new Vuex.Store({
  namespaced: true,
  state: {
    uid: '',
    userImg: '',
    uname: '',
    shop: [],
    inventory: [],
    soleing: [],
    isReload: false,
  },
  mutations: {
    login(state, setup) {
      state.uid = setup.uid
      state.userImg = setup.userImg
      state.uname = setup.uname
    },
    shop(state, setup) {
      state.shop = setup
      console.log(setup)
    },
    inventory(state, setup) {
      state.inventory = setup
    },
    soleing(state, setup) {
      state.soleing = setup
    }
  },
  IS_RELOAD(state) {
    state.isReload = !state.isReload;
  },
  plugins: [createPersistedState()],
})
